import React, { Component } from 'react';
import { StyleSheet, View, Text } from 'react-native';

import { SafeAreaView } from 'react-navigation';

import BaseStyle from '../constants/Style';
import Pwd from '../components/password';

import Btn from '../components/buttons';
import Swt from '../components/switch';
export default class PwdScreen extends Component {
  constructor(props) {
    super(props);
    this.state = {
      modalVisible: false,
      pwdV: '',
      value: false,
      value2: false,
    };
  }

  render() {
    return (
      <SafeAreaView
        style={[BaseStyle.flex, styles.homebg]}
        forceInset={{ top: 'never' }}>
        <Pwd
          modalVisible={this.state.modalVisible}
          closePwd={() => {
            this.setState({ modalVisible: false });
          }}
          checkPwd={this.state.value}
          isOpenVibration={this.state.value2}
          callBackPwd={v => {
            this.setState({ pwdV: v });
          }}
        />
        <View style={styles.container}>
          <Text style={styles.pwdtext}>
            您输入的交易密码为:
            <Text style={styles.redbg}>{this.state.pwdV}</Text>
          </Text>
          <View style={styles.rowView}>
            <Text style={styles.rowText}>是否开启密码校验：</Text>
            <Swt
              value={this.state.value}
              onValueChange={value => {
                this.setState({
                  value: value,
                  ChangeText: value ? '开关打开了' : '开关关闭了',
                });
              }}
            />
          </View>
          <View style={styles.rowView}>
            <Text style={styles.rowText}>是否开启震动效果：</Text>
            <Swt
              value={this.state.value2}
              onValueChange={value => {
                this.setState({
                  value2: value,
                });
                value ? toast('温馨提示:真机下感受效果~') : null;
              }}
            />
          </View>
          <Btn
            text={'去支付'}
            onPress={() => {
              this.setState({ modalVisible: true });
            }}
          />
        </View>
      </SafeAreaView>
    );
  }
}

const styles = StyleSheet.create({
  homebg: {
    backgroundColor: '#eee',
  },
  container: {
    ...BaseStyle.flex,
    paddingTop: 20,
  },
  pwdtext: {
    fontSize: 15,
    color: '#333',
    marginBottom: 30,
    marginLeft: 15,
  },
  rowView: {
    marginBottom: 20,
    marginLeft: 15,
    ...BaseStyle.row,
    ...BaseStyle.alignItemsCenter,
  },
  rowText: {
    fontSize: 15,
    color: '#333',
  },
  redbg: {
    color: 'red',
  },
});
